#****************************************************************************
#
# Makefile for StarCore.
# www.srplab.com
#****************************************************************************
DEBUG          := YES
PROFILE        := NO
#****************************************************************************
CC     := gcc
CXX    := g++
LD     := g++
AR     := ar
RANLIB := ranlib

DEBUG_CFLAGS     := -Wall -Wno-format -g -DDEBUG -DENV_LINUX
RELEASE_CFLAGS   := -Wall -Wno-unknown-pragmas -Wno-format -O3 -DENV_LINUX

LIBS	:= -ldl -lpthread -lrt
EXTRA_LIBS := /usr/lib/libstarlib.a /usr/lib/libuuid.a

DEBUG_CXXFLAGS   := ${DEBUG_CFLAGS} 
RELEASE_CXXFLAGS := ${RELEASE_CFLAGS}

DEBUG_LDFLAGS    := -g
RELEASE_LDFLAGS  :=

ifeq (YES, ${DEBUG})
   CFLAGS       := ${DEBUG_CFLAGS}
   CXXFLAGS     := ${DEBUG_CXXFLAGS}
   LDFLAGS      := ${DEBUG_LDFLAGS}
else
   CFLAGS       := ${RELEASE_CFLAGS}
   CXXFLAGS     := ${RELEASE_CXXFLAGS}
   LDFLAGS      := ${RELEASE_LDFLAGS}
endif

ifeq (YES, ${PROFILE})
   CFLAGS   := ${CFLAGS} -pg -O3
   CXXFLAGS := ${CXXFLAGS} -pg -O3
   LDFLAGS  := ${LDFLAGS} -pg
endif

#****************************************************************************
# Makefile code common to all platforms
#****************************************************************************

CFLAGS   := ${CFLAGS}   ${DEFS}
CXXFLAGS := ${CXXFLAGS} ${DEFS}

#****************************************************************************
# include source and paths
#****************************************************************************

INCS_T := /usr/include/starcore
INCS   = $(addprefix -I,$(INCS_T))

TEST_CXXSRCS := test.cpp SRPSHtmlEnvEngine_UUIDDef.cpp SRPSHtmlEnvEngine_VSClass.cpp

#****************************************************************************
TEST_CXXOBJS := $(TEST_CXXSRCS:%.cpp=%.o) 

#****************************************************************************
CXXOBJS := ${TEST_CXXOBJS}
COBJS := 

EXEC_TEST_OBJS := ${TEST_CXXOBJS}

#****************************************************************************
# Targets of the build
#****************************************************************************
OBJS_PATH = .

EXEC_TEST := ${OBJS_PATH}/test_linux

all: ${EXEC_TEST}

#****************************************************************************
# Output
#****************************************************************************

${EXEC_TEST}: ${EXEC_TEST_OBJS}
	${LD} -o $@ ${LDFLAGS} ${EXEC_TEST_OBJS} ${LIBS} ${EXTRA_LIBS}
	
#****************************************************************************
# common rules
#****************************************************************************

${CXXOBJS} :
	${CXX} ${CXXFLAGS} ${INCS} $< -o $@ -c $*.cpp

${COBJS} : 
	${CC} ${CFLAGS} ${INCS} -o $@ -c $*.c
		
dist:
	bash makedistlinux

clean:
	-rm -f core ${CXXOBJS} ${COBJS} ${EXEC_TEST}

depend:
	#makedepend ${INCS} ${SRCS}
	

